<?php
//父类car
    class Car{
        public $color;
        public $userName;
        public function __construct($color,$userName)
        {
            $this->color=$color;
            $this->userName=$userName;
        }
        public function use(){
        echo "我是机动车";
        }
        public function equals($obj1,$obj2){
            if(($obj1->color==$obj2->color)&&($obj1->userName==$obj2->userName))
            return true;
            return false;
        }
}
// $car1= new Car("红色","张三");
// $car2= new Car("黄色","李四");
// $car1->use();
// var_dump($car1->equals($car1,$car2));
class Texi extends Car{
    public $company;
    public function __construct($company,$color,$userName)
    {
        $this->company=$company;
        parent::__construct($color,$userName);//调用父类的构造函数
    }
    final public function ride(){
        echo $this->userName."出租⻋是所属于在".$this->company."公司的";
    }
    public function use(){
        echo "出租车是提高市民生活质量的重要条件之一";
    }
    public function toString()
    {
        echo $this->color."<br>";
        echo $this->userName;
    }
}
class HomeCar extends Texi{
    public $num;
    public function __construct($num,$company,$color,$userName)
    {
        $this->num=$num;
        parent::__construct($company,$color,$userName);
    }
    public function display(){
        echo $this->userName."拥有的".$this->color."颜色的私家车有".$this->num."座位";
    }
}
?>
